import request from '@/config/axios'

// 题库 VO
export interface BankVO {
  id: number // 主键
  name: string // 名称
  edition: string // 教材版本
  subject: string // 科目
  grade: string // 年级
  semester: string // 学期
}

// 题库 API
export const BankApi = {
  // 查询题库分页
  getBankPage: async (params: any) => {
    return await request.get({ url: `/exam/bank/page`, params })
  },

  // 查询题库详情
  getBank: async (id: number) => {
    return await request.get({ url: `/exam/bank/get?id=` + id })
  },

  // 新增题库
  createBank: async (data: BankVO) => {
    return await request.post({ url: `/exam/bank/create`, data })
  },

  // 修改题库
  updateBank: async (data: BankVO) => {
    return await request.put({ url: `/exam/bank/update`, data })
  },

  // 删除题库
  deleteBank: async (id: number) => {
    return await request.delete({ url: `/exam/bank/delete?id=` + id })
  },

  // 导出题库 Excel
  exportBank: async (params) => {
    return await request.download({ url: `/exam/bank/export-excel`, params })
  },

// ==================== 子表（题库章节） ====================

  // 获得题库章节分页
  getBankChapterPage: async (params) => {
    return await request.get({ url: `/exam/bank/bank-chapter/page`, params })
  },
  // 新增题库章节
  createBankChapter: async (data) => {
    return await request.post({ url: `/exam/bank/bank-chapter/create`, data })
  },

  // 修改题库章节
  updateBankChapter: async (data) => {
    return await request.put({ url: `/exam/bank/bank-chapter/update`, data })
  },

  // 删除题库章节
  deleteBankChapter: async (id: number) => {
    return await request.delete({ url: `/exam/bank/bank-chapter/delete?id=` + id })
  },

  // 获得题库章节
  getBankChapter: async (id: number) => {
    return await request.get({ url: `/exam/bank/bank-chapter/get?id=` + id })
  }
}